package com.wnhz.work.yz.activity;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.wnhz.work.yz.BaseActivity;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.base.BaseRVAdapter;
import com.wnhz.work.yz.base.BaseViewHolder;
import com.wnhz.work.yz.bean.Fa2Bean;
import com.wnhz.work.yz.view.RoundImageView;

import java.util.List;

public class YanShou2ChuFaPinActivity extends BaseActivity implements View.OnClickListener {
    private RecyclerView recycler;
    private Fa2Bean bean = new Fa2Bean();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yan_shou2_chu_fa_pin);
        bean = (Fa2Bean) getIntent().getSerializableExtra("bean");
        if (bean == null) {
            MyToast("暂无数据");
            return;
        }
        TextView title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("处罚详情");
        findViewById(R.id.btn_main_left).setOnClickListener(this);
        //
        TextView name = (TextView) findViewById(R.id.name);
        name.setText(bean.getInfo().getProject_name());
        final TextView hetong = (TextView) findViewById(R.id.hetong);
        hetong.setText("合同编号：" + bean.getInfo().getBudget_no());
        TextView sname = (TextView) findViewById(R.id.sname);
        sname.setText(bean.getInfo().getProject_name());
        TextView ss = (TextView) findViewById(R.id.ss);
        ss.setText(bean.getInfo().getLabel());
        TextView info = (TextView) findViewById(R.id.info);
        info.setText(bean.getInfo().getAddress());
        final RoundImageView img = (RoundImageView) findViewById(R.id.img);
        ImageLoader.getInstance().displayImage(bean.getInfo().getImg(), img);
        //
        TextView dui = (TextView) findViewById(R.id.dui);
        dui.setText(bean.getInfo().getInstall());
        TextView price33 = (TextView) findViewById(R.id.price33);
        price33.setText(bean.getInfo().getPunish_money() + "元");
        TextView remark2 = (TextView) findViewById(R.id.remark2);
        String rema = bean.getInfo().getPunish_remark().replace(";", ";\n");
        remark2.setText(Html.fromHtml(rema));
        //
        final List<Fa2Bean.InfoEntity.ListEntity> list = bean.getInfo().getList();
        recycler = (RecyclerView) findViewById(R.id.recycler);
        recycler.setLayoutManager(new GridLayoutManager(this, 3, LinearLayoutManager.VERTICAL, false));
        //  recycler.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL, 1, getResources().getColor(R.color.line_color)));
        recycler.setAdapter(new BaseRVAdapter(this, list) {
            @Override
            public int getLayoutId(int viewType) {
                return R.layout.item_chufa;
            }

            @Override
            public void onBind(BaseViewHolder holder, int position) {
                ImageLoader.getInstance().displayImage(list.get(position).getImg(), holder.getImageView(R.id.img));
                holder.setTextView(R.id.name, list.get(position).getName());
                holder.setTextView(R.id.price, "处罚:" + list.get(position).getAmount() + "元");
                holder.setTextView(R.id.info, list.get(position).getInfo());
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_main_left:
                finish();
                break;

        }
    }
}
